package com.winderinfo.yikaotianxia.ui.mockexam;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.winderinfo.yikaotianxia.ui.classification.FragmentText;
import com.winderinfo.yikaotianxia.ui.home.ZhuanYeBean;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class AnswerFAdapter extends FragmentPagerAdapter {

    private List<AnswerBean.RowsBean> mTableList;
    private int cardid;
    private AnswerBean answerBean;
    private int id;

    public AnswerFAdapter(FragmentManager fm, List<AnswerBean.RowsBean> mTableList, int cardid, AnswerBean answerBean, int id) {
        super(fm);
        this.mTableList = mTableList;
        this.cardid = cardid;
        this.answerBean = answerBean;
        this.id = id;
    }


    @Override
    public Fragment getItem(int i) {
        if (i < mTableList.size()) {
            AnswerFragment answerFragment = new AnswerFragment();
            Bundle bundle = new Bundle();
            bundle.putSerializable("list", mTableList.get(i));
            bundle.putInt("sum", mTableList.size());
            bundle.putInt("num", i);
            bundle.putInt("cardid", cardid);
            answerFragment.setArguments(bundle);
            return answerFragment;
        } else {
            AnswerCardFragment answerCardFragment = new AnswerCardFragment();
            Bundle bundle = new Bundle();
            bundle.putSerializable("data", answerBean);
            bundle.putInt("id", id);
            bundle.putInt("cardid", cardid);
            answerCardFragment.setArguments(bundle);
            return answerCardFragment;
        }

    }

    @Override
    public int getCount() {
        return mTableList.size() + 1;
    }

}
